from flask import render_template
from blueprints import personal_blueprint
from blueprints.personal.api.information import PersonalInformation
from tools.decorate import pack_session
from tools.model import PackInstance, QueryOneInstance


@personal_blueprint.route('/information', methods=['GET' ])
@pack_session
def information(data):
    data[PersonalInformation.__name__] = PackInstance(QueryOneInstance(PersonalInformation,{"uid":data['session']['uid']}))
    data['writeable']=True
    return render_template('pages/personal/information.html',data=data)

@personal_blueprint.route('/information/<int:uid>', methods=['GET'])
@pack_session
def information_uid(data):
    data[PersonalInformation.__name__] = PackInstance(QueryOneInstance(PersonalInformation,{"uid":data['route']['uid']}))
    data['writeable']= (data['session']['uid'] == data['route']['uid'])
    return render_template('pages/personal/information.html',data=data)




